<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<script language="javascript" type="text/javascript" >
function insert(element, start, eind) 
{
element = document.getElementById(element);
if (document.selection) 
{
element.focus();
sel = document.selection.createRange();
sel.text = start + sel.text + eind;
} 
else if (element.selectionStart || element.selectionStart == '0') 
{
element.focus();
var startPos = element.selectionStart;
var endPos = element.selectionEnd;
element.value = element.value.substring(0, startPos) + start + element.value.substring(startPos, endPos) + eind + element.	value.substring(endPos, element.value.length);
} 
else 
{
element.value += start + eind;
}
}
</script>
<body>
<h1>simple text editor</h1>

<form action="index.html" method="post">
<table>
<tr>
<td valign="top"><label for="text_editor">Text:</label></td>
<td><textarea cols="80" rows="20" name="text_editor" id="text_editor"></textarea></td>
</tr> 
<tr>
<td>action</td>

<td>
<?php
    foreach($emoticons as $emo):
        $img = $emo['image'];
        $code = $emo['code'];
        echo "<img src=\"$img\" alt=\"$code\" onclick=\"insert('text_editor', '$code', '')\">";
    endforeach
?>
    <?php echo createEmoticonElement(':beauty:'); ?>
<button type="button" onclick="insert('text_editor', '', '');" title="Bold" style="font-weight: bold;">B</button>
<button type="button" onclick="insert('text_editor', '', '');" title="Underlined" style="text-decoration: underline;">U</button>
<button type="button" onclick="insert('text_editor', '', '');" title="Italic" style="font-style: italic;">I</button>
<button type="button" onclick="insert('text_editor', '', '[hr]');" title="Horizontal rule">&mdash;</button>
<button type="button" onclick="insert('text_editor', '', '');" title="Subscript">Sub</button>
<button type="button" onclick="insert('text_editor', '', '');" title="Superscript">Super</button>
</td>
</tr>
</table>
</form>
</body>
</html>

